import { IColumnProps } from "devextreme-react/data-grid"
import { consts } from "../../../consts";
/**
 * 风险系统表
 */

export const expansionCoefficientDataSource = [
    { acceptableRisk: '1%', expansionCoefficient: 1.9 },
    { acceptableRisk: '5%', expansionCoefficient: 1.6 },
    { acceptableRisk: '10%', expansionCoefficient: 1.5 },
    { acceptableRisk: '15%', expansionCoefficient: 1.4 },
    { acceptableRisk: '20%', expansionCoefficient: 1.3 },
    { acceptableRisk: '25%', expansionCoefficient: 1.25 },
    { acceptableRisk: '30%', expansionCoefficient: 1.2 },
    { acceptableRisk: '37%', expansionCoefficient: 1.15 },
    { acceptableRisk: '50%', expansionCoefficient: 1.1 },

]
export function getExpansionCoefficientColumns(): IColumnProps[] {
    return [
        {
            dataField: "acceptableRisk",
            alignment: 'center',
            caption: '可接受风险水平',
            allowFiltering: false,
            allowSorting: false,
            width: 150,
        },
        {
            dataField: "expansionCoefficient",
            alignment: 'center',
            caption: '扩张系数',
            allowFiltering: false,
            allowSorting: false,
            width: 150,
        },
    ]
}
export const expansionCoefficientColumns = getExpansionCoefficientColumns()


/**
 * 获取扩张系数
 * @param acceptableRisk 
 */
export function getExpansionCoefficient(acceptableRisk: string): number {
    const riskCoefficient: any = expansionCoefficientDataSource.find(item => item.acceptableRisk == acceptableRisk);
    if (riskCoefficient) {
        return Number(riskCoefficient.expansionCoefficient || 0)
    }
    return 0;
}